﻿using Architecture.API.Application.Command.UserInfoCommand;
using Architecture.Domain;
using Architecture.Domain.Service.UserInfoServices;
using MediatR;

namespace Architecture.API.Application.CommandHandlers.UserInfoHandler
{
    /// <summary>
    /// 用户信息反向填充命令处理器
    /// </summary>
    public class UserInfoReverseFillingCommandHandler : IRequestHandler<UserInfoReverseFillingCommand, UserInfo>
    {
        /// <summary>
        /// 用户信息服务
        /// </summary>
        private readonly IUserInfoService _userInfoService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="userInfoService">用户信息服务</param>
        public UserInfoReverseFillingCommandHandler(IUserInfoService userInfoService)
        {
            _userInfoService = userInfoService;
        }


        /// <summary>
        /// 用户信息反向填充命令处理器
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken">取消标记</param>
        /// <returns>返回用户信息实体</returns>
        public Task<UserInfo> Handle(UserInfoReverseFillingCommand request, CancellationToken cancellationToken)
        {
            return _userInfoService.GetModelAsync(request.UserId);
        }
    }
}
